package design.State;

/**
 * Created by looper on 2017/8/24.
 */
public class Context {
  private State state;

  public Context(State state){
    this.state = state;
  }

  public State getState() {
    return state;
  }

  public void setState(State state) {
    this.state = state;
    System.out.print("当前状态是 :"+state.getStateName());
    if(StateName.CLOAKING.equals(state.getStateName())){
      System.out.println("   对好友不可见.");
    }else{
      System.out.println("     对好友可见.");
    }
  }

  public void changeState(){
    this.state.changeState(this);
  }
}
